package qc.module.qms.api;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * QmsApiApplication
 *
 * @author QuCheng Tech
 * @since 2024/1/23
 */
@SpringBootApplication
@ComponentScan({"qc.common.core"})//需要对qc.common.core封装的进行扫描，aspect中有数据库查询的selectOne添加limit 1
@MapperScan("qc.module.qms.repository")//不扫描repository在service中找不到对应的repository
@ComponentScan({"qc.module.qms.service"})//不扫描service在controller中找不到对应的service
@ComponentScan({"qc.module.qms.api.controller"})//不扫描controller从gateway找不到对应的微服务
@EnableSwagger2
@EnableScheduling
public class QmsApiApplication {
    public static void main(String[] args) {
        SpringApplication.run(QmsApiApplication.class, args);
    }

    @Bean
    @LoadBalanced // 开启负载均衡 Ribbon, 发送的请求都会被Ribbon拦截。必须使用应用名代替ip，否则报错
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}